package com.xuecheng.content.api;

import com.xuecheng.content.model.dto.AddCourseTeacherDto;
import com.xuecheng.content.model.dto.EditCourseTeacherDto;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description TODO
 * @Author dingchunlin
 * @Date 2024/3/30 11:21
 * @Version 1.0.0
 */
@Api(value = "教师信息接口",tags = "教师信息接口")
@RestController
public class CourseTeacherController {

    @Autowired
    CourseTeacherService courseTeacherService;


    @ApiOperation("根据课程id查询教师信息")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacher> selectByCourseId(@PathVariable Long courseId){
        List<CourseTeacher> courseTeacherList = courseTeacherService.selectByCourseId(courseId);
        return courseTeacherList;
    }

    @ApiOperation("添加或修改课程教师信息")
    @PostMapping("/courseTeacher")
    public CourseTeacher saveCourseTeacher(@RequestBody EditCourseTeacherDto courseTeacherDto){
        Long companyId = 1232141425L;
        CourseTeacher courseTeacher = courseTeacherService.saveOrEditCourseTeacher(companyId,courseTeacherDto);
        return courseTeacher;
    }

    @ApiOperation("删除课程教师信息")
    @DeleteMapping("/courseTeacher/course/{courseId}/{courseTeacherId}")
    public void deleteCourseTeacher( @PathVariable(value = "courseId",required = true) Long courseId ,
                                     @PathVariable(value = "courseTeacherId",required = true) Long courseTeacherId){
        Long companyId = 1232141425L;
        courseTeacherService.deleteCourseTeacher(companyId,courseId,courseTeacherId);
    }
}
